<?php
//dezend by http://www.yunlu99.com/ QQ:270656184
defined('BASEPATH') || exit('No direct script access allowed');
$this->load->helper('url');
?>	<table id="tt" class="easyui-datagrid"></table>
	
	<div id="tb" style="padding:10px;5px;height:auto">
		<div>
			编号: <input id="id" class="easyui-textbox" style="width:80px">
			用户名: <input id="username" class="easyui-textbox" style="width:100px">
			日期 从: <input id="start" class="easyui-datebox" style="width:100px">
			到: <input id="end" class="easyui-datebox" style="width:100px">
			状态：
			<select id="status" class="easyui-combobox" style="width:100px">
				<option value="-1">全部</option>
				<option value="0">等待处理</option>
				<option value="1">已通过</option>
				<option value="2">处理中</option>
				<option value="3">未通过</option>
			</select>
			<a href="#" onclick="doSearch()" class="easyui-linkbutton" iconCls="icon-search">搜索</a>
			<script type="text/javascript">
			function doSearch(){
				$('#tt').datagrid('load',{
					id: $('#id').val(),
					username: $('#username').val(),
					start: $('#start').val(),
					end: $('#end').val(),
					status: $('#status').val()
				});
			}
			</script>
		</div>
		<div style="margin-top:10px">
			<a href="#" class="easyui-linkbutton" iconCls="icon-cut" plain="true" id="del">删除</a>
		</div>
	</div>
	
	<div id="win"></div>

<script language="javascript">

$(function(){
	$('#tt').datagrid({
		url:'<?php echo site_url('pic_apply/data');?>',
		pagination:true,
		toolbar:'#tb',
		pageSize:20,
		checkbox:true,
		fit:true,
		fitColumns:true,
		border:false,
		idField:'id',
		nowrap:true,
		autoRowHeight:true,
		'columns':[[
			{field:'ck',checkbox:'true'},
			{field:'id',width:'9%',title:'编号'},
			{field:'username',width:'10%',title:'帐号'},
			{field:'name',width:'10%',title:'姓名'},
			{field:'idtype_name',width:'10%',title:'证件类型'},
			{field:'idno',width:'20%',title:'身份证号'},
			{field:'info',width:'10%',title:'回复说明'},
			{field:'add_time',width:'10%',title:'申请时间'},
			{field:'status',width:'10%',title:'是否通过',formatter:function(value,row,index){if(row.status==0)return '未审核';else if(row.status==1) return '是';else  return '否';}},
			{field:'action',width:'10%',title:'操作',formatter:function(value,row,index){if(row.status==0)return '<a href="javascript:doedit('+row.id+')" iconCls="icon-edit" class="easyui-linkbutton list_link">审核</a>';else return '<a href="javascript:doinfo('+row.id+')" iconCls="icon-search" class="easyui-linkbutton list_link">查看</a>';}}
		]],
		onLoadSuccess:function(data){$(".list_link").linkbutton()}
	});

	$('#win').window({
		width:'100%',
		height:'100%',
		modal:true,
		closed:true,
		title:'添加/修改'
	});

	$('#del').click(function(){
		var rows = $('#tt').datagrid('getChecked');
		if(rows.length == 0){  
			$.messager.alert('Info','请至少选择一行数据！','info');
			return false;  
		}

		var ids = [];
		$.each(rows,function(index,item){
			ids.push(item.id);
		});
		
		$.messager.confirm('确认信息','您确定要删除吗？删除之后不能恢复',function(r){
			if(r){
				$.getJSON('<?php echo site_url('pic_apply/del');?>',{'id[]':ids},function(d){
					$.messager.alert('信息提示',d.msg,'info');
					
					if(d.error == 0){
						$('#tt').datagrid('reload');
					}
				});
			}
		});
		
	});
});

function doedit(id){
	$('#win').window('open');
	$('#win').window('refresh', '<?php echo site_url('pic_apply/edit/\'+id+\'');?>');
}

function doinfo(id){
	$('#win').window('open');
	$('#win').window('refresh', '<?php echo site_url('pic_apply/info/\'+id+\'');?>');
}

</script>